package com.yaowk.system.server.controller;

import com.yaowk.common.api.PageReq;
import com.yaowk.common.api.PageResp;
import com.yaowk.system.api.ResourceApi;
import com.yaowk.system.api.model.Resource;
import com.yaowk.system.server.service.IResourceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "资源")
public class ResourceController implements ResourceApi {

    @Autowired
    private IResourceService resourceService;

    @Override
    @ApiOperation("资源列表")
    public PageResp<Resource> list(Resource resource, PageReq pageReq) {
        return resourceService.findAll(resource, pageReq);
    }

    @Override
    @ApiOperation("资源详情")
    public Resource findOne(@PathVariable Long id) {
        return resourceService.findById(id);
    }

    @Override
    @ApiOperation("保存资源")
    public Resource save(Resource resource) {
        return resourceService.save(resource);
    }

    @Override
    @ApiOperation("删除资源")
    public void delete(@PathVariable Long id) {
        resourceService.deleteById(id);
    }
}
